package br.com.equus.DAO.impl;

import java.util.List;

import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import org.springframework.stereotype.Repository;

import br.com.equus.DAO.manejoDAO;
import br.com.equus.entidade.Produto;

@Repository(value = "manejoDAO")
public class ManejoDAOImpl extends HibernateDaoSupport implements manejoDAO {

	@Autowired(required = true)
	public void setFactory(SessionFactory factory) {
		super.setSessionFactory(factory);
	}

	@Override
	public List<Produto> carregaProdutosPNome(String query) throws Exception {
		String q = "from Produto p where upper (p.descricao) like '%"+query.toUpperCase()+"%'";
		return getSession().createQuery(q).list();
	}

}
